<style scoped lang="less">
  .opinion {
    padding-top: 100px;
    .title {
      color: #252B63;
      font-size: 26px;
      text-align: center;
    }
    .form {
      padding-top: 50px;
      .form-item {
        overflow: hidden;
      }
    }
    .btn{
      background: url("../../../static/image/t_1.png") center center no-repeat;
      width: 260px;
      line-height: 50px;
      font-size: 20px;
      color: #fff;
      text-align: center;
      margin: 50px auto 0;
      cursor: pointer;
    }
  }
  #opinion{
    padding:0 100px;
  }
</style>
<template>
  <div id="opinion">
    <div class="opinion">
      <div class="title">
        提交您对平台的意见或建议
      </div>
      <div class="form">
        <Form>
          <FormItem class="form-item">
            <Input size="large" v-model="comTitle" placeholder="请输入标题"/>
          </FormItem>
          <FormItem class="form-item">
            <Input size="large" type="textarea" :rows="20" v-model="comContent" placeholder="请输入内容"/>
          </FormItem>
        </Form>
      </div>
      <div @click="complaint" class="btn">
        提交
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'PersonalOpinion',
    data () {
      return {
        comContent: '',
        comTitle: ''
      }
    },
    methods: {
      complaint: function () {
        let that = this
        let title = that.comTitle
        let content = that.comContent
        if (title === '') {
          that.$vux.toast.show({
            text: '请输入标题',
            width: '200px',
            position: 'middle',
            type: 'text'
          })
          return false
        }
        if (content === '') {
          that.$vux.toast.show({
            text: '请输入内容',
            width: '200px',
            position: 'middle',
            type: 'text'
          })
          return false
        }
        that.$chaos.ajax({
          url: '/User/submitOpinion',
          userinfo: true,
          data: {
            title: title,
            content: content
          },
          callback: function (type, res) {
            if (type === 'success') {
              that.$vux.toast.show({
                text: '提交成功',
                width: '200px',
                position: 'middle',
                type: 'text'
              })
              that.comTitle = ''
              that.comContent = ''
            }
          }
        })
      },
      setCrumbs: function () {
        let crumbs = []
        crumbs[0] = {
          title: '个人中心',
          link: ''
        }
        crumbs[1] = {
          title: '平台意见',
          link: ''
        }
        this.$store.commit('crumbs', crumbs)
      }
    },
    created () {
      this.$emit('changeCurrent', 6)
      this.setCrumbs()
    },
    activated () {
      this.setCrumbs()
    }
  }
</script>
